package cate.game.play.skill.passive.furniture;

import cate.common.table.d.GDSkill;
import cate.game.play.base.TargetFilterParam;
import cate.game.play.base.TargetSelector;
import cate.game.play.config.PlayCfgArgs;
import cate.game.play.fighter.Fighter;
import cate.game.play.proce.action.ctx.ActionCtx;
import cate.game.play.skill.passive.PassiveHandler;

import java.util.List;

/**
 * 奇数回合为自己和额外1名友方单位附加5%攻击和45%穿透，偶数回合为自己和额外1名友方单位附加5%暴伤减免和15%抗控
 */
public class 奇偶相关PH extends PassiveHandler {

	private int 友方人数;

	private int 奇数buff;

	private int 偶数buff;

	//友方人数=1&奇数buff=？？&偶数buff=？？
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		友方人数 = args.getInt("友方人数", 0);
		奇数buff = args.getInt("奇数buff", 0);
		偶数buff = args.getInt("偶数buff", 0);
	}

	@Override
	public void onRoundBegin(ActionCtx action) {
		if (skill.owner.isDead()) {
			return;
		}
		List<Fighter> fighters = TargetSelector.doFind(skill.owner, action.getTeamVs(),
				new TargetFilterParam().scopeSet(GDSkill.Scope.FRIENDS).targetNumSet(友方人数));
		fighters.add(skill.owner);
		int buff = action.getRound().isOddRound() ? 奇数buff : 偶数buff;
		for (Fighter fighter : fighters) {
			fighter.buff.tryAddByTid(action, skill.owner, buff);
		}
	}
}
